#include "httpsserver.hpp"

bool onget(HTTPSServer* s,HTTPSServer::ThreadInfo* from,HTTPSServer::Request* r){
	r->print();
	auto url=r->url;
	if(url->type()==Resource::res_file)if(s->sendfile(from,r,(File*)url,true))return true;
	s->response(from,r,400,"invalid url",HTTPSServer::defaulttable,nullptr,0,false);
	return true;
}

int main(){
	if(HTTPSServer::openlib()){
		auto ret=HTTPSServer("../testroot",deflate,{{"GET",{onget,true}}}).
		run("./privatekey.pem","./cert.crt","127.0.0.1",443);
		HTTPSServer::closelib();
		return ret;
	}
	return -1;
}